home *** CD-ROM | disk | FTP | other *** search
- Path: bbs.ug.eds.com!berryb
- Newsgroups: comp.lang.c
- Subject: Pointer to read file...
- Message-ID: <1996Apr19.110223@bbs.ug.eds.com>
- From: berryb@bbs.ug.eds.com (High Plains GRIPster (TRW C.S.D.))
- Date: 19 Apr 96 11:02:23 PDT
- Organization: TRW C.S.D.
- Nntp-Posting-Host: bbs
-
- 4/19/96
-
- I have a beginners C question.
- After going page by page through my Learning C book,
- I am still in a quandry.
-
- I have a pointer to a file: FILE *fp;
-
- I have a pointer to a pointer: FILE **p2f = &fp;
-
- I have a character pointer: char*fname="/user2/bcb/grip/unix/c/listing";
-
- After I open my file... if ( (fp = fopen (file1, "r")) != NULL)
-
- I want to be able to use the p2f pointer, which is pointing at
- the beginning of the file, to read the character that it is
- pointing at...and then move to the next character and read
- that character until EOF is reached.
-
- I am able to increment the pointers position by p2f++;
- but I am unable to read the character. This is probably
- because I need a character pointer to read a character,
- and the FILE pointer just cant perform that way.
-
- If I try to use this line: char **p2f = &fp;
- it errors on compilation saying types FILE* and char*
- are incompatible as used. I thought about using a
- void pointer and casting it to a character pointer?
-
- I wish I had more experience at this.
-
- brett
-
-